﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Fabrica
{
    public partial class AgregarMaterial : Form
    {
        public AgregarMaterial()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            FabricaEntities entities = new FabricaEntities();

            entities.AddToMaterials(
                new Material
                {
                    description = textBox2.Text,
                    name = textBox1.Text,
                    materialId = (from t in entities.Materials
                                  select t).Count() + 1
                });
            entities.SaveChanges();
            MessageBox.Show("Material Agregado con exito");
        }


    }
}
